package com.dingding.nettyserver.modular.taxi.push.impl;

import org.springframework.stereotype.Component;

import com.aliyun.openservices.ons.api.Action;
import com.dingding.common.core.push.pushbean.specialdriver.AppointTaxiOrderPushBean;
import com.dingding.common.core.push.pushmsg.TcpPushPack;
import com.dingding.common.core.util.JSONUtil;
import com.dingding.nettyserver.common.handler.AbstractPushHandler;
import com.dingding.nettyserver.common.protocolbuf.PushProtobuf.TaxiOrderAppoint;
import com.dingding.nettyserver.core.util.DateKit;
import com.dingding.nettyserver.core.util.NumUtil;
import com.dingding.nettyserver.modular.taxi.push.ITaxiPushHandler;

/**
 * @Description 出租车业务，推送模块
 * @author fengshuonan
 * @date 2016年11月30日 下午5:12:17
 */
@Component
public class TaxiPushHandlerImpl extends AbstractPushHandler implements ITaxiPushHandler {

	/**
	 * @Description 指派订单推送
	 * @author fengshuonan
	 */
	@Override
	public Action appointOrder(TcpPushPack tcpPushPack) {
		AppointTaxiOrderPushBean o = JSONUtil.parseObject(tcpPushPack.getContent(),
				AppointTaxiOrderPushBean.class);
		TaxiOrderAppoint taxiOrderAppoint = TaxiOrderAppoint.newBuilder().setNickName(o.getNickName()).setSex(o.getSex())
				.setTelePhone(o.getTelePhone()).setUserAvatar(o.getUserAvatar()).setUserTabloidAvatar(o.getUserTabloidAvatar()).setOid(o.getOid())
				.setDistance(NumUtil.keep2Point(o.getDistance().doubleValue())).setEndAddress(o.getEndAddress()).setEndLatitude(NumUtil.latLngPoint(o.getEndLatitude()))
				.setEndLongitude(NumUtil.latLngPoint(o.getEndLongitude())).setOrderStatus(o.getOrderStatus()).setSetOutTime(DateKit.getTime(o.getSetOutTime()))
				.setSetOutType(o.getSetOutType()).setStartAddress(o.getStartAddress()).setStartLatitude(NumUtil.latLngPoint(o.getStartLatitude())).setStartLongitude(NumUtil.latLngPoint(o.getStartLongitude()))
				.setOutTime(o.getOutTime()).setEstimateDuration(o.getEstimateDuration()).setStartDistance(NumUtil.keep2Point(o.getStartDistance().doubleValue())).setOtherUserId(o.getOtherUserId()).setEstimateDistance(NumUtil.keep2Point(o.getEstimateDistance().doubleValue()))
				.setEstimateMoney(NumUtil.keep1Point(o.getEstimateMoney().doubleValue())).setTotalMoney(NumUtil.keep1Point(o.getTotalMoney().doubleValue())).setPublishType(o.getPublishType()).build();
		return super.pushToClient(tcpPushPack,taxiOrderAppoint);
	}

}
